//
//  HTCommentsView.swift
//  weibo
//
//  Created by JonsonLiu on 2017/3/7.
//  Copyright © 2017年 JonsonLiu. All rights reserved.
//

import UIKit

class HTCommentsView: UIView {

  
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    
    func setupUI(){
//        backgroundColor = UIColor(colorLiteralRed: Float(arc4random()%255)/255, green: Float(arc4random()%255)/255, blue: Float(arc4random()%255)/255, alpha: 1)
        let leftButton = addButton(title: "转发", iamged: "timeline_icon_retweet")
        let commonButton = addButton(title: "评论", iamged: "timeline_icon_comment")
        let rightButton = addButton(title: "点赞", iamged: "timeline_icon_unlike")
        
        leftButton.snp.makeConstraints { (make) in
            make.leading.top.bottom.equalTo(self)
            make.width.equalTo(commonButton)
        }
        commonButton.snp.makeConstraints { (make) in
            make.top.bottom.equalTo(self)
            make.leading.equalTo(leftButton.snp.trailing)
//            make.trailing.equalTo(rightButton.snp.leading)
            make.width.equalTo(rightButton)
        }
        rightButton.snp.makeConstraints { (make) in
            make.top.bottom.trailing.equalTo(self)
            make.leading.equalTo(commonButton.snp.trailing)
            
            make.width.equalTo(leftButton)
        }
    }
    
    
    func addButton(title: String,iamged:String) -> UIButton{
    
        let button = UIButton()
        
        button.setTitle(title, for: .normal)
        button.setImage(UIImage(named:iamged), for: .normal)
        button.setBackgroundImage(UIImage(named:"timeline_card_bottom_background_highlighted"), for: .highlighted)
        button.setBackgroundImage(UIImage(named:"timeline_card_bottom_background"), for: .normal)
        button.tintColor = UIColor.black
        button.setTitleColor(UIColor.black, for: .normal)
        addSubview(button)
        
        return button
    }
    
    
}
